package com.anzhen.interview.xml.data;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlValue;
import java.util.List;

/**
 * <data name="SOURCE_TYPE">
 *     <field length="2" scale="0" type="string">MT</field>
 * </data>
 * Created by anzhen on 2017-5-3.
 */
@XmlRootElement(name = "data")
@XmlAccessorType(XmlAccessType.FIELD)
public class Data {
	@XmlAttribute(name = "name")
	private String name;

	@XmlElement(name = "field")
	private Filed filed;

	@XmlElement(name = "array")
	private Array array;

	@XmlRootElement(name = "array")
	@XmlAccessorType(XmlAccessType.FIELD)
	public static class Array {
		private List<Struct> struct;

		public List<Struct> getStruct() {
			return struct;
		}

		public void setStruct(List<Struct> struct) {
			this.struct = struct;
		}
	}

	@XmlRootElement(name = "struct")
	@XmlAccessorType(XmlAccessType.FIELD)
	public static class Struct {
		private List<Data> data;

		public List<Data> getData() {
			return data;
		}

		public void setData(List<Data> data) {
			this.data = data;
		}
	}


	@XmlRootElement(name = "field")
	@XmlAccessorType(XmlAccessType.FIELD)
	public static class Filed{
		@XmlAttribute(name = "length")
		private String length;
		@XmlAttribute(name = "scale")
		private String scale;
		@XmlAttribute(name = "type")
		private String type;
		@XmlValue
		private String value;

		public String getLength() {
			return length;
		}

		public void setLength(String length) {
			this.length = length;
		}

		public String getScale() {
			return scale;
		}

		public void setScale(String scale) {
			this.scale = scale;
		}

		public String getType() {
			return type;
		}

		public void setType(String type) {
			this.type = type;
		}

		public String getValue() {
			return value;
		}

		public void setValue(String value) {
			this.value = value;
		}
	}


	public Data() {
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Filed getFiled() {
		return filed;
	}

	public void setFiled(Filed filed) {
		this.filed = filed;
	}

	public Array getArray() {
		return array;
	}

	public void setArray(Array array) {
		this.array = array;
	}
}
